package com.bdqn.service;

import com.bdqn.mapper.SysUserMapper;
import com.bdqn.pojo.SysRole;
import com.bdqn.pojo.SysUser;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService{
    private SysUserMapper sysUserMapper;
    @Override
    public List<SysUser> getList(SysUser sysUser) {
        try {
            return sysUserMapper.selectSysUserList(sysUser);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Transactional
    @Override
    public boolean add(SysUser sysUser) {
        try {
            return sysUserMapper.add(sysUser);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Transactional
    @Override
    public int del(int id) {
        try {
            return sysUserMapper.del(id);
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }

    }

    @Override
    public int upd(int id, String password) {
        try {
            return sysUserMapper.upd(id, password);
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }

    }

    @Override
    public int updateId(SysRole sysRole) {
        try {
            return sysUserMapper.updateId(sysRole);
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int deleteUser(Integer userId) {
        try {
            return sysUserMapper.deleteUser(userId);
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int delete(Integer id) {
        try {
            return sysUserMapper.delete(id);
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
    }


    public SysUserMapper getSysUserMapper() {
        return sysUserMapper;
    }

    public void setSysUserMapper(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }
}
